package com.yanqu.road.server.cmd.orewar;

import com.yanqu.road.pb.orewar.OreWarProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.orewar.CrossOreWarMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;


@Cmd(code = Protocol.C_CROSS_OREWAR_UNION_INFO_SYNC, desc = "同步商会的解散加入退出被踢乱七八糟的冠名的变化发放奖励")
public class CrossUnionInfoSyncCmd extends CrossUnionCommand {

    private int type;//0普通同步，1解散商会，2商会成员退出或者加入或者被踢
    private long serverId;
    private long userId;//加入或者退出商会
    private String unionUid;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        OreWarProto.CrossOreWarUnionChangeMsg reqMsg = OreWarProto.CrossOreWarUnionChangeMsg.parseFrom(packet.getBytes());
        type = reqMsg.getType();
        serverId = reqMsg.getServerId();
        userId = reqMsg.getUserId();
        unionUid = reqMsg.getUnionUid();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossOreWarMgr.unionInfoSync(type,serverId,userId,unionUid,groupId);
    }

    @Override
    public void sendData() {

    }

}
